import request from '@/router/axios';

// 查询
export const getList = (current, size, params, deptId) => {
  return request({
    url: '/api/blade-user/getUserListPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      deptId,
    }
  })
}

// 删除
export const remove = (ids) => {
  return request({
    url: '/api/blade-user/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

// 新增
export const add = (row) => {
  return request({
    url: '/api/blade-user/save',
    method: 'post',
    data: row
  })
}

// 修改
export const update = (row) => {
  return request({
    url: '/api/blade-user/updateUserInfo',
    method: 'post',
    data: row
  })
}

// 修改平台配置
export const updatePlatform = (userId, userType, userExt) => {
  return request({
    url: '/api/blade-user/update-platform',
    method: 'post',
    params: {
      userId,
      userType,
      userExt,
    }
  })
}

// 详情
export const getUser = (id) => {
  return request({
    url: '/api/blade-user/getUserDetail',
    method: 'get',
    params: {
      id,
    }
  })
}

// 获取平台配置列表
export const getUserPlatform = (id) => {
  return request({
    url: '/api/blade-user/platform-detail',
    method: 'get',
    params: {
      id,
    }
  })
}

// 获取用户信息
export const getUserInfo = () => {
  return request({
    url: '/api/blade-user/info',
    method: 'get',
  })
}

// 重置密码
export const resetPassword = (userIds) => {
  return request({
    url: '/api/blade-user/reset-password',
    method: 'post',
    params: {
      userIds,
    }
  })
}

// 更新密码
export const updatePassword = (oldPassword, newPassword, newPassword1) => {
  return request({
    url: '/api/blade-user/update-password',
    method: 'post',
    params: {
      oldPassword,
      newPassword,
      newPassword1,
    }
  })
}

// 更新信息
export const updateInfo = (row) => {
  return request({
    url: '/api/blade-user/update-info',
    method: 'post',
    data: row
  })
}

// 角色配置
export const grant = (userIds, roleIds) => {
  return request({
    url: '/api/blade-user/grant',
    method: 'post',
    params: {
      userIds,
      roleIds,
    }
  })
}

// 人员状态更新
export const updateUserStatus = (userIds, ryzt) => {
  return request({
    url: '/api/blade-user/personnelStatusTransition',
    method: 'post',
    params: {
      userIds,
      ryzt,
    }
  })
}

// 绑定工卡
export const bindLocationCard = (id, gk) => {
  return request({
    url: '/api/blade-user/bindWorkCard',
    method: 'post',
    params: {
      id,
      gk
    }
  })
}

// 获取工卡列表
export const getLocationCards = () => {
  return request({
    url: '/api/locationCard/locationcardinfo/list',
    method: 'get'
  })
}

// 获取所有未绑定定位卡（不包括所选人员）
export const getUnbindLocationCards = () => {
  return request({
    url: '/api/locationCard/locationcardinfo/unbindList',
    method: 'get'
  })
}

// 获取所有未绑定定位卡（包括所选人员）
export const getUnbindUserList = (userId) => {
  return request({
    url: '/api/locationCard/locationcardinfo/unbindUserList',
    method: 'get',
    params: {
      userId
    }
  })
}

// 生成二维码
export const generateQRCode = (id) => {
  return request({
    url: '/api/blade-user/generateQRCode',
    method: 'post',
    params: {
      id
    }
  })
}